<?include_once('conn.php');?>
<?include_once('inc_head.php');?>
<?include_once('admin_statistics_class.php');?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="./js/echarts.js"></script>
<style>
	form.layui-form{padding:0px!important;}
</style>
<body>
<?local("问卷数据统计");?>
<div id="intro">
	<!-- ******************************主内容开始****************************** -->
	<!-- 地区选择 -->
	<form class="layui-form">
		<blockquote class="layui-elem-quote layui-quote-nm">
				<div class="layui-form-item">
					<div class="layui-form-mid layui-word-aux">问卷类型</div>
					<div class="layui-input-inline"> <? show_qn_filter(); ?> </div>
				</div>
		</blockquote>
		<blockquote class="layui-elem-quote layui-quote-nm">
				<div class="layui-form-item">
				<div class="layui-form-mid layui-word-aux">请选择地区</div>
					<div class="layui-input-inline">
					<select name="province" class="layui-select" id="province" lay-verify="required" lay-filter="province">
						<option value="">请选择省份</option>
					</select>
					</div>
					<div class="layui-input-inline">
					<select name="city" class="layui-select" id="city" lay-verify="required" lay-filter="city">
						<option value="">请选择市</option>
					</select>
					</div>
					<div class="layui-input-inline">
					<select name="area" class="layui-select" id="area" lay-verify="required" lay-filter="area">
						<option value="">请选择县区</option>
					</select>
					</div>
					<div class="layui-input-inline">
					<select name="scope" class="layui-select" id="scope" lay-verify="required" lay-filter="scope">
						<option value="">请选择园区</option>
					</select>
					</div>
					<div class="layui-input-inline">
						<a class="layui-btn layiu-btn-primary layui-btn-radius" id="JS-doStatic" data-title="">
							<i class="layui-icon">&#xe666;</i>统计
						</a>
					</div>
				</div> </blockquote>
	</form>
	<!-- 显示 -->
	<h5 class="statistic"></h5>
	<hr>
	<div class="admin-main">
		<div id="main" style="width: 100%;height:500px;"></div>
	</div>
	<!-- ******************************主内容结束*********************************** -->
</div>
<!-- ***********************************脚本区域************************************* -->
<script src="./plugins/layui/layui.all.js"></script>
<script src="./js/vbyzc.js"></script>
<script>

	// 执行队列
	pm(resolve => resolve())
	.then(()=>{
		return pm(
			(resolve)=>{
				// 加载省份
				vtool.ajax({
					type: 'GET', url : API_ADDR_PROVINCE, data: {},
					cb:(res)=>{
						console.log(res)
						res.dataList.forEach(item =>{ $("#province").append(`<option value="${item.name},${item.provinceid}">${item.name}</option>`); });
						form.render();
						resolve()
					}
				})
			}
		)
	})
	.then(()=>{ return pm( (resolve)=>{ resolve() } ) })
	.then(()=>{ console.log('执行完成') })

	

	// 省份下拉菜单事件
	form.on('select(province)', function(data){
		const province = data.value.split(',')
		// console.log('省份：',province)
		$("#city,#area,#scope").html('<option value="">请选择</option>');
		vtool.ajax({
			type: 'GET', url : API_ADDR_CITY, data: {provinceid:province[1]},
			cb:(res)=>{
				if(res.dataList){
					res.dataList.forEach(item =>{ 
						$("#city").append(`<option value="${item.name},${item.cityid}">${item.name}</option>`); 
					});
					form.render();
				}
			}
		})
	});

	// 城市下拉菜单事件
	form.on('select(city)', function(data){
		const city = data.value.split(',')
		// console.log('城市',city)
		$("#area,#scope").html('<option value="">请选择</option>');
		vtool.ajax({
			type: 'GET', url : API_ADDR_AREA, data: {cityid:city[1]},
			cb:(res)=>{
				if(res.dataList){
					res.dataList.forEach(item =>{
						$("#area").append(`<option value="${item.name},${item.areaid}">${item.name}</option>`); 
					});
					form.render();
				}
			}
		})
	});

	// 县区下拉菜单事件：加载园区
	form.on('select(area)', function(data){
		const area = data.value.split(',')
		// console.log('县区：',area)
		$("#scope").html('<option value="">请选择</option>');
		vtool.ajax({
			type: 'GET', url : API_ADDR_SCOPE, data: {areaid:area[1]},
			cb:(res)=>{
				if(res.dataList){
					res.dataList.forEach(item =>{
						$("#scope").append(`<option value="${item.name},${item.id}">${item.name}</option>`); 
					});
				}
				form.render();
			}
		})
	});

	//*************************绑定额外的按钮事件 *****************************************


</script>
<script src="js/page_statistics.js"></script>
<?include('inc_foot.php');?>
</body>
</html>